package main

import (
	"fmt"
	"log"
)
// 定义一个interface 接口
type proc interface {
	Name()
}

type Server struct {
	name string
	node *Node
}

type Client struct {
	name string
	node *Node
}
type Node struct {
	year int
	proc
}

func (s *Server)Name() {
	fmt.Println("server" + s.name)
}
func (s *Client)Name() {
	fmt.Println("client" + s.name)
}

func newServer(name string) *Server {
	s := &Server {
		name: name,
		node: &Node{
			year: 10,
		},
	}
	s.node.proc = s
	return s
}

func newCient(name string) *Client {
	s := &Client {
		name: name,
		node: &Node{
			year: 10,
		},
	}
	s.node.proc = s
	return s
}

type state struct {
	intValue int
	strintValue string
}

func (s *state)Name() {
	fmt.Println(s.strintValue)
}



type stateStart state
type stateConfigured state

var start = &stateStart{1, "start"}
var configured = &stateConfigured{2, "configured"}

func (s *stateStart)next() stInterface {
	fmt.Println("configured")
	return configured
}
func (s *stateConfigured)next()  stInterface {
	fmt.Println("prepared")
	return start
}

type stInterface interface {
	next() stInterface
	Name()
}

func main() {
	s := newServer("test")
	n := s.node
	n.proc.Name()

	c := newCient("cls")
	c.node.proc.Name()

	log.Println(start.strintValue)
	a := start.next()
	a.Name()


}
